/*
 * Powered By www.cardmee.net
 */
package com.ns.school.service.wave.impl;

import com.ns.school.common.utils.DateUtil;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ns.school.common.utils.JsonUtil;
import com.ns.school.po.edu.LayuiResult;
import com.ns.school.po.sys.User;
import lombok.extern.slf4j.Slf4j;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ns.school.mapper.wave.WaveStationMapper;
import com.ns.school.po.wave.WaveStationPO;
import com.ns.school.service.base.BaseService;
import com.ns.school.service.wave.WaveStationService;

/**
 * @author wt-97
 */
@Slf4j
@Service
public class WaveStationServiceImpl extends BaseService implements WaveStationService {

    @Autowired
    private WaveStationMapper waveStationMapper;

    @Override
    public List<User> selectAllNames(Map<String, Object> map) {
        return waveStationMapper.getNames(map);
    }

    /**
     * 查询全部
     */
    @Override
    public void findAll(WaveStationPO waveStationPO) {
        List<WaveStationPO> list =waveStationMapper.queryList(waveStationPO);
        log.info(JsonUtil.toStr(list));
        Map<Integer,WaveStationPO> map = new HashMap<>();
        for (WaveStationPO waveStationPO1 : list) {
            map.put(waveStationPO1.getId(),waveStationPO1);
        }

        for(Map.Entry<Integer,WaveStationPO> entry:map.entrySet()){
            System.out.println("Key = " + entry.getKey() + ", Value = " + entry.getValue());
        }

    }

    @Override
    public List<WaveStationPO> findAllStations(WaveStationPO waveStationPO) {
        return waveStationMapper.findAllStations(waveStationPO);
    }

    //添加

    @Override
    public void addStation(WaveStationPO waveStationPO, LayuiResult<WaveStationPO> result) {
        Date date=new Date();
        waveStationPO.setCreateTime(date);
        Integer addStation=waveStationMapper.addStation(waveStationPO);
        if (addStation>0) {
            result.setCode(0);
            result.setMsg("新增成功");
        }

    }





    /**
     * 删除
     */
    @Override
    public void updateDel(LayuiResult result,WaveStationPO params)  {
        params.setUpdateTime(DateUtil.getNowDate());
        if (waveStationMapper.updateDel(params) == 0) {
            transactionRollBack();
            result.setMsg("删除失败");
        }
        result.setMsg("删除成功");
    }

    @Override
    public Integer stationUpdate(Integer ids) {
        return waveStationMapper.stationUpdate(ids);
    }



    @Override
    public WaveStationPO selecWaveStation(Integer id) {
        return waveStationMapper.selecWaveStation(id);
    }

    @Override
    public Integer upStation(WaveStationPO waveStationPO) {
        return waveStationMapper.upStation(waveStationPO);
    }


}
